﻿// ActionScript file
package org.nickro.3D.pv3d
{
	import flash.display.MovieClip;
	
	import org.papervision3d.materials.MovieMaterial;
	import org.papervision3d.objects.DisplayObject3D;
	import org.papervision3d.objects.primitives.Plane;
	
	public class TwoSidedPlane extends DisplayObject3D{
		private var froPlane:Plane;
		private var bacPlane:Plane;
		private var planeGroup:Plane;
		
		private var _selected:Boolean = false;
		public function TwoSidedPlane(frontMC:MovieClip,backMC:MovieClip){
			createMovieMaterial(frontMC,backMC);
		}
		private function createMovieMaterial(_frontMC:MovieClip,_backMC:MovieClip):void
		{
			var frontMovieMat:MovieMaterial=new MovieMaterial(_frontMC,true,true,true);
			frontMovieMat.interactive=true;
			frontMovieMat.smooth=true;
			froPlane=new Plane(frontMovieMat,0,0,3,3);
			
			var backMovieMat:MovieMaterial=new MovieMaterial(_backMC,true,true,true);
			backMovieMat.interactive=true;
			backMovieMat.smooth=true;
			bacPlane=new Plane(backMovieMat,0,0,5,5);
			
			this.addChild(froPlane);
			this.addChild(bacPlane);
			bacPlane.rotationY=180;
		}
		public function destroy():void
		{
			this.removeChild(froPlane);
			this.removeChild(bacPlane);
		}
		
		public function get frontPlane():Plane{
			return froPlane;
		}
		public function get backPlane():Plane{
			return bacPlane;
		}
		
		public function set selected(value:Boolean):void
		{
			_selected = value;
		}
		public function get selected():Boolean
		{
			return _selected;
		}
	}
}